import request from '@/utils/request'

export default {
  getItemList(searchModel) {
    return request({
      url: '/item/list',
      method: 'get',
      params: {
        itemName: searchModel.itemName,
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  addItem(item) {
    return request({
      url: '/item/add',
      method: 'post',
      data: item
    })
  },
  saveItem(item) {
    if (item.itemId == null || item.itemId === undefined) {
      return this.addItem(item)
    }
    return this.updateItem(item)
  },
  updateItem(item) {
    return request({
      url: '/item/update',
      method: 'put',
      data: item
    })
  },
  getItemById(id) {
    return request({
      // url: '/item/' + id,
      url: `/item/${id}`,
      method: 'get'
    })
  },
  deleteItemById(id) {
    return request({
      url: `/item/delete/${id}`,
      method: 'delete'
    })
  },
  getAllItemList() {
    return request({
      url: '/item/all',
      method: 'get'
    })
  },
}
